import request from '@/utils/request'

// ==================== 面试预约管理相关API ====================

// 查询面试预约列表
export function listInterviewAppointment(query) {
  return request({
    url: '/campus/interviewAppointment/list',
    method: 'get',
    params: query
  })
}

// 获取面试预约详细信息
export function getInterviewAppointment(appointmentId) {
  return request({
    url: '/campus/interviewAppointment/' + appointmentId,
    method: 'get'
  })
}

// 确认面试预约
export function confirmAppointment(appointmentId) {
  return request({
    url: '/campus/interviewAppointment/confirm/' + appointmentId,
    method: 'put'
  })
}

// 批量确认预约
export function batchConfirmAppointments(data) {
  return request({
    url: '/campus/interviewAppointment/batchConfirm',
    method: 'put',
    data: data
  })
}

// 完成面试并评价
export function completeInterview(data) {
  return request({
    url: '/campus/interviewAppointment/complete',
    method: 'put',
    data: data
  })
}

// 根据社团ID查询预约列表
export function getAppointmentsByClub(clubId) {
  return request({
    url: '/campus/interviewAppointment/club/' + clubId,
    method: 'get'
  })
}

// 根据面试时段ID查询预约列表
export function getAppointmentsBySlot(slotId) {
  return request({
    url: '/campus/interviewAppointment/slot/' + slotId,
    method: 'get'
  })
}

// 获取社团的预约统计
export function getClubAppointmentStatistics(clubId) {
  return request({
    url: '/campus/interviewAppointment/statistics/club/' + clubId,
    method: 'get'
  })
}

// 获取面试时段的预约统计
export function getSlotAppointmentStatistics(slotId) {
  return request({
    url: '/campus/interviewAppointment/statistics/slot/' + slotId,
    method: 'get'
  })
}

// 发送预约提醒
export function sendAppointmentReminder(appointmentId) {
  return request({
    url: '/campus/interviewAppointment/remind/' + appointmentId,
    method: 'post'
  })
}

// 批量发送预约提醒
export function batchSendReminders(appointmentIds) {
  return request({
    url: '/campus/interviewAppointment/batchRemind',
    method: 'post',
    data: appointmentIds
  })
}

// 查询需要提醒的预约
export function getAppointmentsForReminder(hours = 2) {
  return request({
    url: '/campus/interviewAppointment/reminders',
    method: 'get',
    params: {
      hours: hours
    }
  })
}

// 查询过期未处理的预约
export function getExpiredAppointments() {
  return request({
    url: '/campus/interviewAppointment/expired',
    method: 'get'
  })
}

// 自动处理过期预约
export function processExpiredAppointments() {
  return request({
    url: '/campus/interviewAppointment/processExpired',
    method: 'put'
  })
}

// 重新安排面试时间
export function rescheduleAppointment(data) {
  return request({
    url: '/campus/interviewAppointment/reschedule',
    method: 'put',
    data: data
  })
}

// 检查学生是否有时间冲突
export function checkStudentTimeConflict(studentId, slotId) {
  return request({
    url: '/campus/interviewAppointment/checkConflict/student',
    method: 'get',
    params: {
      studentId: studentId,
      slotId: slotId
    }
  })
}

// 检查面试官是否有时间冲突
export function checkInterviewerTimeConflict(interviewerId, slotId) {
  return request({
    url: '/campus/interviewAppointment/checkConflict/interviewer',
    method: 'get',
    params: {
      interviewerId: interviewerId,
      slotId: slotId
    }
  })
}
